<template>
    <div>
        <h2>添加</h2>
        <table>
            <thead>
                <tr>
                    <td>会员姓名</td>
                    <td><input type="text"  v-model="data.Name"></td>
                </tr>
                <tr>
                    <td>等级名称</td>
                    <td><input type="text"  v-model="data.VipName"></td>
                </tr>
                <tr>
                    <td colspan="2"><input type="button" value="添加" @click="Add"></td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
//函数注入
import axios from 'axios';
import { ref } from 'vue';
import { useRoute } from 'vue-router';
//定义变量
const data=ref({
"Id": 0,
"Name": "",
"VipName": "",
"Vip": true,
"Time": "2025-03-23T10:19:48.018Z"
})

const Add=()=>{
    axios.post("https://localhost:7034/api/Vip/AddVip",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功");
            location.href="/show";
        }
        else{
            alert("添加失败");
           
        }
    })
    }
</script>

<style scoped>

</style>